import React, { Component } from 'react'
import store from '../../Redux/store'
import { incrementaction,decrementaction,multiplieraction,divisionaction} from '../../Redux/count_reducer'



export default class Operational extends Component {
  //加法
  increment = () => {
    const {value} = this.selectNumber
    // store.dispatch({type:'increment',data:value * 1})
     store.dispatch(incrementaction(value *1))
    
  }

  //减法
  decrement = () => {
    const { value } = this.selectNumber
   store.dispatch(decrementaction(value *1))
    
  }
  
  //乘法
  multiplier = () => {
    const { value } = this.selectNumber
     store.dispatch(multiplieraction(value *1))
    
  }

  //除法
  division = () => {
    const { value } = this.selectNumber
     store.dispatch(divisionaction(value *1))
    
  }
  
  render() {
    return (
     <div>
        <h1>当前求和的值为{store.getState()}</h1>   
        <select ref={c => this.selectNumber = c}>
          <option value="1">1</option>
          <option value="2">2</option>
          <option value="3">3</option>
        </select>

        <button onClick={this.increment}>+</button>
        <button onClick={this.decrement}>-</button>
        <button onClick={this.multiplier}>*</button>
       <button onClick={this.division}>/</button>
      </div>
    )
  }
}
